package org.ank.food;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.FilterQueryProvider;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class ConfirmExperienceActivity extends Activity{
	
	private final static int FOOD_AMOUNT_DIALOG_CODE = 0;
	private final static int RESULT_FROM_ADD_PRODUCT = 1;
	protected final static int SHOW_ALL_MODE = 0;
	protected final static int SHOW_GROUPS_MODE = 1;
	protected final static int SHOW_SUBGROUPS_FROM_GROUP_MODE = 2;
	protected final static int SHOW_PRODUCTS_FROM_SUBGROUP_MODE = 3;
	protected final static int SHOW_GROUPS_FOR_ADVICE_MODE = 4;
	protected final static int SHOW_PRODUCTS_FROM_GROUP_MODE = 5;
	public final static String INTENT_EXTRA_NAME_MODE = "conf_exp_extra";
	public final static String INTENT_EXTRA_NAME_SUBGROUP = "subgroup_extra";

	
	private TextView title;
	private ListView listView;
	private SimpleCursorAdapter adapter;
//	private ProductsAdapter productsAdapter;
	private Button changeModeButton, backButton;
	private int mode, lastGroup, lastSubgroup;
	private ProgressBar progressBar;
	
	
	protected int selectedProductId;
	
	
	
	
	@Override
	public void onCreate(Bundle b){
		super.onCreate(b);
		setContentView(R.layout.confirm_experience_activity);
		
		setTitle(
				getString(R.string.app_name)+" - "+getString(R.string.title_profile)+": "+
				ProfileManager.getInstance(getApplicationContext()).getCurrentProfileName()
				);
		
		changeModeButton = (Button)findViewById(R.id.confirm_experience_change_mode_button);
		backButton = (Button)findViewById(R.id.confirm_experience_back_button);
		title = (TextView)findViewById(R.id.confirm_experience_title);
		progressBar = (ProgressBar)findViewById(R.id.confirm_experience_progressbar);
//		title.sette
		
		
//		//Log.v("conf exp", "mode is "+mode);
		listView = (ListView)findViewById(R.id.confirm_experience_list);
		listView.setTextFilterEnabled(true);
		lastGroup = -1;
		lastSubgroup = -1;
		
		Intent parentIntent = getIntent();
//		//Log.v("confExp",""+parentIntent.getIntExtra(ConfirmExperienceActivity.INTENT_EXTRA_NAME_SUBGROUP,-20) );
		if (parentIntent.hasExtra(INTENT_EXTRA_NAME_SUBGROUP)){
			mode = SHOW_PRODUCTS_FROM_SUBGROUP_MODE;
			int subGroupId = parentIntent.getIntExtra(INTENT_EXTRA_NAME_SUBGROUP, 0);
//			//Log.v("ConfExp","sbgrp "+subGroupId);
			setMode(mode, subGroupId, 0);
		}else{
			mode = parentIntent.getIntExtra(INTENT_EXTRA_NAME_MODE, SHOW_GROUPS_MODE);
			setMode(mode, 0, 0);
		}
	}
	
	private void setMode(int newMode, final int id, final int parentId){

		mode = newMode;
		
		switch(newMode){
		case SHOW_ALL_MODE:
			title.setText(R.string.confirm_experience_start_typing_name);
			changeModeButton.setText(R.string.confirm_experience_show_groups);
			changeModeButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					setMode(SHOW_GROUPS_MODE, 0, 0);
				}
			});
			backButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					Intent intent = new Intent();
            		intent.setClass(getApplicationContext(), EatenTodayActivity.class);
            		startActivity(intent);
					finish();
				}
			});
			adapter = new SimpleCursorAdapter(getApplicationContext(),
					android.R.layout.simple_list_item_1, 
					ProductDataManager.getInstance(getApplicationContext()).getAllProductNames(),
					new String[]{ProductDataProvider.COLUMN_NAMES_PRODUCTS[ProductDataProvider.NAME]},
					new int[]{android.R.id.text1});
			adapter.setFilterQueryProvider(new FilterQueryProvider(){
				@Override
				public Cursor runQuery(CharSequence constraint) {
					return getApplicationContext().getContentResolver().query(
							ProductDataProvider.CONTENT_URI_PRODUCTS,
							new String[]{ProductDataProvider.COLUMN_NAMES_PRODUCTS[ProductDataProvider.ID],
								ProductDataProvider.COLUMN_NAMES_PRODUCTS[ProductDataProvider.NAME]},
							ProductDataProvider.COLUMN_NAMES_PRODUCTS[ProductDataProvider.NAME]+
							" LIKE \"%" +constraint+"%\"", null,
							ProductDataProvider.COLUMN_NAMES_PRODUCTS[ProductDataProvider.NAME]);
					}
				});
			listView.setAdapter(adapter);
			listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
				@Override
				public void onItemClick(AdapterView parent, View view, int pos,
						long row) {
//					TextView textView = (TextView)  ((ViewGroup)view).getChildAt(0);
//					AdviceManager.getInstance(getApplicationContext()).
//						saveNewEaten(textView.getText().toString());
//					AdviceManager.getInstance(getApplicationContext()).
//					saveNewEaten((int)row);
//					Intent intent = new Intent();
//	        		intent.setClass(getApplicationContext(), EatenTodayActivity.class);
//	        		startActivity(intent);
//	        		finish();
					selectedProductId = (int) row;
					progressBar.setVisibility(View.VISIBLE);

					Intent intent = new Intent();
	        		intent.setClass(getApplicationContext(), AddProductActivity.class);
	        		intent.putExtra(AddProductActivity.INTENT_EXTRA_NAME_PROD_ID, selectedProductId);
	        		startActivityForResult(intent,RESULT_FROM_ADD_PRODUCT);

				}
			});
			listView.setTextFilterEnabled(true);
			break;
			
		case SHOW_GROUPS_MODE:
			title.setText(R.string.confirm_experience_choose_group);
			changeModeButton.setText(R.string.confirm_experience_show_all);
			changeModeButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					setMode(SHOW_ALL_MODE, 0, 0);
					lastSubgroup = -1;
					lastGroup = -1;
				}
			});
			backButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					Intent intent = new Intent();
            		intent.setClass(getApplicationContext(), EatenTodayActivity.class);
            		startActivity(intent);
					finish();
				}
			});
			adapter = new SimpleCursorAdapter(getApplicationContext(),
					android.R.layout.simple_list_item_1, 
					ProductDataManager.getInstance(getApplicationContext()).getGroupsNames(),
					new String[]{
						ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.GROUP_NAME]
					},
					new int[]{android.R.id.text1});
			adapter.setFilterQueryProvider(new FilterQueryProvider(){
				@Override
				public Cursor runQuery(CharSequence constraint) {
					return getApplicationContext().getContentResolver().query(
							ProductDataProvider.CONTENT_URI_GROUPS,
							new String[]{ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.ID],
								ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.GROUP_NAME]},
							ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.GROUP_NAME]+
							" LIKE \"%" +constraint+"%\"", null,
							ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.GROUP_NAME]);
					}
				});
			listView.setAdapter(adapter);
			if(lastGroup >= 0)
				listView.setSelection(lastGroup);
			listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
				@Override
				public void onItemClick(AdapterView parent, View view, int pos,
						long row) {
					setMode(SHOW_SUBGROUPS_FROM_GROUP_MODE, (int)row, 0);
					lastGroup = pos;
				}
			});
			break;
		
		case SHOW_GROUPS_FOR_ADVICE_MODE:
//			//Log.v("conf_exp","in SHOW_GROUPS_FOR_ADVICE_MODE");
			setContentView(R.layout.confirm_experience_activity_advice_mode);
			listView = (ListView)findViewById(R.id.confirm_experience_list_advice_mode);
			adapter = new SimpleCursorAdapter(getApplicationContext(),
					android.R.layout.simple_list_item_1, 
					ProductDataManager.getInstance(getApplicationContext()).getGroupsNames(),
					new String[]{
						ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.GROUP_NAME]
					},
					new int[]{android.R.id.text1});
			adapter.setFilterQueryProvider(new FilterQueryProvider(){
				@Override
				public Cursor runQuery(CharSequence constraint) {
					return getApplicationContext().getContentResolver().query(
							ProductDataProvider.CONTENT_URI_GROUPS,
							new String[]{ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.ID],
								ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.GROUP_NAME]},
							ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.GROUP_NAME]+
							" LIKE \"%" +constraint+"%\"", null,
							ProductDataProvider.COLUMN_NAMES_GROUPS[ProductDataProvider.GROUP_NAME]);
					}
				});
			listView.setAdapter(adapter);
			listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
				@Override
				public void onItemClick(AdapterView parent, View view, int pos,
						long row) {
					Intent intent = new Intent();
        			intent.setClass(getApplicationContext(), EatenTodayActivity.class);
        			intent.putExtra(EatenTodayActivity.INTENT_EXTRA_NAME,
            				(int)row);
        			startActivity(intent);
        			finish();
				}
			});
			break;	
			
		case SHOW_SUBGROUPS_FROM_GROUP_MODE:
			title.setText(R.string.confirm_experience_choose_subgroup);
			changeModeButton.setText(R.string.confirm_experience_show_all);
			changeModeButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					setMode(SHOW_ALL_MODE, 0, 0);
					lastSubgroup = -1;
					lastGroup = -1;
				}
			});
			backButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					setMode(SHOW_GROUPS_MODE, 0, 0);
					lastSubgroup = -1;
				}
			});
			Cursor c = ProductDataManager.getInstance(getApplicationContext()).
				getSubgroupsNames(id);
			c.moveToFirst();
			if(c.getCount() == 0){
//				//Log.v("conf exp","parentId = "+parentId);
				c.close();
				setMode(SHOW_PRODUCTS_FROM_GROUP_MODE, id, 0);
				break;
			}
			adapter = new SimpleCursorAdapter(getApplicationContext(),
					android.R.layout.simple_list_item_1, 
					c,
					new String[]{
						ProductDataProvider.COLUMN_NAMES_SUBGROUPS[ProductDataProvider.
						                                           SUBGROUP_NAME_SUBGROUPS]
					},
					new int[]{android.R.id.text1});
			adapter.setFilterQueryProvider(new FilterQueryProvider(){
				@Override
				public Cursor runQuery(CharSequence constraint) {
					return getApplicationContext().getContentResolver().query(
							ProductDataProvider.CONTENT_URI_SUBGROUPS,
							new String[]{ProductDataProvider.COLUMN_NAMES_SUBGROUPS[ProductDataProvider.ID],
								ProductDataProvider.COLUMN_NAMES_SUBGROUPS[ProductDataProvider.
								                                           SUBGROUP_NAME_SUBGROUPS]},
							ProductDataProvider.COLUMN_NAMES_SUBGROUPS[ProductDataProvider.
							                                          SUBGROUP_NAME_SUBGROUPS]+
							" LIKE \"%" +constraint+"%\" AND "+
							ProductDataProvider.COLUMN_NAMES_SUBGROUPS[ProductDataProvider.GROUP_ID_SUBGROUPS]+
							" = "+String.valueOf(id)
							, null, 
							ProductDataProvider.COLUMN_NAMES_SUBGROUPS[ProductDataProvider.
							                                           SUBGROUP_NAME_SUBGROUPS]);
					}
				});
			listView.setAdapter(adapter);
			listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
				@Override
				public void onItemClick(AdapterView parent, View view, int pos,
						long row) {
					setMode(SHOW_PRODUCTS_FROM_SUBGROUP_MODE, (int)row, (int)id);
					lastSubgroup = pos;
				}
			});
			if(lastSubgroup>=0)
				listView.setSelection(lastSubgroup);
			break;
			
		case SHOW_PRODUCTS_FROM_GROUP_MODE:
			//Log.v("conf exp","in show pr from group, id = "+id);
			title.setText(R.string.confirm_experience_choose_product);
			changeModeButton.setText(R.string.confirm_experience_show_all);
			changeModeButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					setMode(SHOW_ALL_MODE, 0, 0);
					lastSubgroup = -1;
					lastGroup = -1;
				}
			});
			backButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					setMode(SHOW_GROUPS_MODE, 0, 0);
				}
			});
			adapter = new SimpleCursorAdapter(getApplicationContext(),
					android.R.layout.simple_list_item_1, 
					ProductDataManager.getInstance(getApplicationContext()).
							getProductsByGroup(id),
					new String[]{
						ProductDataProvider.COLUMN_NAMES_PRODUCTS[ProductDataProvider.
						                                           NAME]
					},
					new int[]{android.R.id.text1});
			adapter.setFilterQueryProvider(new FilterQueryProvider(){
				@Override
				public Cursor runQuery(CharSequence constraint) {
					return ProductDataManager.getInstance(getApplicationContext()).
							getProductsByGroupFiltered(id, constraint.toString());
					}
				});
			listView.setAdapter(adapter);
			listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
				@Override
				public void onItemClick(AdapterView parent, View view, int pos,
						long row) {
//					TextView textView = (TextView)  ((ViewGroup)view).getChildAt(0);
//					AdviceManager.getInstance(getApplicationContext()).
//						saveNewEaten(textView.getText().toString());
					
//					AdviceManager.getInstance(getApplicationContext()).
//							saveNewEaten((int)row);
					progressBar.setVisibility(View.VISIBLE);
					selectedProductId = (int) row;
					
//					productsAdapter.toggle(pos);
//					//Log.v("listView","pressed on pos "+pos);
					
					Intent intent = new Intent();
	        		intent.setClass(getApplicationContext(), AddProductActivity.class);
	        		intent.putExtra(AddProductActivity.INTENT_EXTRA_NAME_PROD_ID, selectedProductId);
//	        		intent.putExtra("a", 101010);
//	        		//Log.v("conf exp","spi = "+intent.getIntExtra(AddProductActivity.INTENT_EXTRA_NAME_PROD_ID,
//	        				-100));
//	        		//Log.v("conf exp","spi = "+intent.getIntExtra("a",
//	        				-100));
//	        		intent.putExtra(AddProductActivity.INTENT_EXTRA_NAME_SUBGROUP, id);
	        		startActivityForResult(intent,RESULT_FROM_ADD_PRODUCT);
//	        		finish();						
//					showDialog(FOOD_AMOUNT_DIALOG_CODE);
				}
			});
			break;
		case SHOW_PRODUCTS_FROM_SUBGROUP_MODE:
			title.setText(R.string.confirm_experience_choose_product);
			changeModeButton.setText(R.string.confirm_experience_show_all);
			changeModeButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					setMode(SHOW_ALL_MODE, 0, 0);
					lastSubgroup = -1;
					lastGroup = -1;
				}
			});
			backButton.setOnClickListener(new Button.OnClickListener(){
				@Override
				public void onClick(View v) {
					setMode(SHOW_SUBGROUPS_FROM_GROUP_MODE, parentId, 0);
				}
			});
			adapter = new SimpleCursorAdapter(getApplicationContext(),
					android.R.layout.simple_list_item_1, 
					ProductDataManager.getInstance(getApplicationContext()).
							getProductsBySubgroup(id),
					new String[]{
						ProductDataProvider.COLUMN_NAMES_PRODUCTS[ProductDataProvider.
						                                           NAME]
					},
					new int[]{android.R.id.text1});
			adapter.setFilterQueryProvider(new FilterQueryProvider(){
				@Override
				public Cursor runQuery(CharSequence constraint) {
					return ProductDataManager.getInstance(getApplicationContext()).
							getProductsBySubgroupFiltered(id, constraint.toString());
					}
				});
			listView.setAdapter(adapter);
			listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
				@Override
				public void onItemClick(AdapterView parent, View view, int pos,
						long row) {
//					TextView textView = (TextView)  ((ViewGroup)view).getChildAt(0);
//					AdviceManager.getInstance(getApplicationContext()).
//						saveNewEaten(textView.getText().toString());
					
//					AdviceManager.getInstance(getApplicationContext()).
//							saveNewEaten((int)row);
					progressBar.setVisibility(View.VISIBLE);
					selectedProductId = (int) row;
					
//					productsAdapter.toggle(pos);
//					//Log.v("listView","pressed on pos "+pos);
					
					Intent intent = new Intent();
	        		intent.setClass(getApplicationContext(), AddProductActivity.class);
	        		intent.putExtra(AddProductActivity.INTENT_EXTRA_NAME_PROD_ID, selectedProductId);
//	        		intent.putExtra("a", 101010);
//	        		//Log.v("conf exp","spi = "+intent.getIntExtra(AddProductActivity.INTENT_EXTRA_NAME_PROD_ID,
//	        				-100));
//	        		//Log.v("conf exp","spi = "+intent.getIntExtra("a",
//	        				-100));
//	        		intent.putExtra(AddProductActivity.INTENT_EXTRA_NAME_SUBGROUP, id);
	        		startActivityForResult(intent,RESULT_FROM_ADD_PRODUCT);
//	        		finish();						
//					showDialog(FOOD_AMOUNT_DIALOG_CODE);
				}
			});
			break;
			
			
		}
	}
	
	protected void onActivityResult(int requestCode, int resultCode,
            Intent data) {
		progressBar.setVisibility(View.INVISIBLE);
        if (requestCode == RESULT_FROM_ADD_PRODUCT) {
            if (resultCode == RESULT_OK) {
            	Intent intent = new Intent();
				intent.setClass(getApplicationContext(), EatenTodayActivity.class);
				startActivity(intent);
				finish();
            }
        }
    }
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			switch(mode){
			case SHOW_GROUPS_FOR_ADVICE_MODE:
					Intent intent = new Intent();
					intent.setClass(getApplicationContext(), EatenTodayActivity.class);
					startActivity(intent);
					finish();	
				break;
				default:
					backButton.performClick();
			}
			return true;			
		}
	    return super.onKeyDown(keyCode, event);
	}
	
//	private String getProductInfo(int id){
//		return "";
//	}
//	private boolean productIsAcceptable(int id){
//		return true;
//	}
/*	
	private class ProductsAdapter extends SimpleCursorAdapter{
		
		private boolean expanded[];
		private Cursor cursor;
		
		public ProductsAdapter(Context context, int layout, Cursor c, 
				String[] from, int[] to) {
			super(context, layout, c, from, to);
			cursor = c;
			cursor.moveToFirst();
			expanded = new boolean[cursor.getCount()];
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
//			RelativeLayout v, infoView;
			LinearLayout v;
			TextView title, info;
			Button addButton;
			boolean acceptable;
			int id;
			
			if (convertView != null){
				v = (LinearLayout)convertView;
				title = (TextView)v.getChildAt(0);
				info = (TextView)v.getChildAt(1);
//				addButton = (Button)v.getChildAt(2);
								
			}else{
				Context context = getApplicationContext();
////				XmlPullParser parser = context.getResources().
////						getXml(R.id.product_item_view);
////				AttributeSet attributes = Xml.asAttributeSet(parser);
//				AttributeSet attributes = context.getResources().
//						getLayout(R.layout.product_list_item);
				v  = new LinearLayout(context);
				title = new TextView(context);
				title.setTextSize(
						context.getResources().getDimension(R.dimen.text_size_25)
						);
				title.setTextColor(
						context.getResources().getColor(R.color.color_of_ordinary_text)
						);
				info = new TextView(context);
				info.setTextSize(
						context.getResources().getDimension(R.dimen.text_size_24)
						);
				info.setTextColor(
						context.getResources().getColor(R.color.color_of_ordinary_text)
						);
				addButton = new Button(context);
				addButton.setText(R.string.product_list_add);
				addButton.setMinWidth(
						context.getResources().getDimensionPixelSize(R.dimen.button_width_3)
						);
				addButton.setTextSize(
						context.getResources().getDimension(R.dimen.text_size_25)
						);
				v.addView(title, new LinearLayout.
						LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
				v.addView(info, new LinearLayout.
						LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
//				v.addView(addButton, new LinearLayout.
//						LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
				
//				v = (RelativeLayout)findViewById(R.id.product_item_view);
			}
//			//Log.v("getView","v = "+v);
//			//Log.v("getView","v.id = "+v.getId());
//			//Log.v("getView","v.getChildCount() = "+v.getChildCount());
//			//Log.v("getView","v.getChildAt(0) = "+v.getChildAt(0));
//			
//			//Log.v("getView","title = "+title.getText());
			
			
			cursor.moveToPosition(position);
			
			id = cursor.getInt(1); 
//			acceptable = productIsAcceptable(id);
			String s = cursor.getString(0);
//			//Log.v("getView","id = "+id+", title = "+s);
			title.setText(cursor.getString(0));
			info.setText("info");
			
//			title.setTextColor(acceptable ? Color.WHITE : Color.MAGENTA);
			
			if(!expanded[position]){
				info.setVisibility(View.GONE);
//				addButton.setVisibility(View.GONE);
				return v;
			}
			
			info.setText(getProductInfo(id));
//			info.setTextColor(acceptable ? Color.WHITE : Color.MAGENTA);
//			addButton.setOnClickListener(new Button.OnClickListener(){
//				@Override
//				public void onClick(View arg0) {
//					showDialog(FOOD_AMOUNT_DIALOG_CODE);
//				}
//			});
			info.setVisibility(View.VISIBLE);
//			addButton.setVisibility(View.VISIBLE);
			
			return v;
		}
		
		public void toggle(int position) {
			//Log.v("toggle","togle pos "+position+" where expanded is "+expanded[position]);
            if(expanded[position]){
            	expanded[position] = false;
            	//Log.v("toggle","now expanded["+position+"] is "+expanded[position]);
            	notifyDataSetChanged();
            	return;
            }
            for(int i = 0; i < expanded.length; i++)
            	expanded[i] = false;
            expanded[position] = true;
            notifyDataSetChanged();
        }
		
		
	}
	
	@Override
	public Dialog onCreateDialog(int code){
		
		AlertDialog.Builder builder = new AlertDialog.Builder(ConfirmExperienceActivity.this);
		
		return null;
	}
	
	private View createViewForDialog(int prodId){
		ProductDataManager prdM = ProductDataManager.getInstance(getApplicationContext());
		Context context = getApplicationContext();
		RelativeLayout layout = new RelativeLayout(context);
		TextView title = new TextView(context);
		title.setTextSize(
				context.getResources().getDimension(R.dimen.text_size_25)
				);
		title.setTextColor(
				context.getResources().getColor(R.color.color_of_ordinary_text)
				);
		title.setText(prdM.getProductNameById(prodId));
//		Spinner
		
		
		return layout;
	}
	
*/
}
